import logging

from UI_web_wms.page import Page
import time
from selenium.webdriver.common.by import By
from selenium import webdriver
class Page2(Page):
    xiexin_loc = (By.XPATH, '//*[@id="_mail_component_98_98"]/span[2]')
    def xiexin(self):
        self.click(self.xiexin_loc)

    shoujian_loc=(By.CLASS_NAME,'nui-editableAddr-ipt')
    def shoujian(self):
        self.send_keys(self.shoujian_loc,'3409851406@qq.com')
    zhuti_loc=(By.XPATH,'//input[contains(@id,"subjectInput")]')
    def zhuti(self):
        self.send_keys(self.zhuti_loc,'Web端UI自动化')
    iframe_loc=(By.CLASS_NAME,'APP-editor-iframe')
    def iframe(self):
        self.frame(self.iframe_loc)

    body_loc=(By.XPATH,'/html/body')
    def body(self):
        self.send_keys(self.body_loc,'移动66666666666')

    send_loc=(By.CSS_SELECTOR,'.nui-btn-text')
    def send(self):
        self.click(self.send_loc)
    dy_loc=(By.XPATH,'/html/body/div[2]/div[1]/div/div[2]/section/h1')
    def dy(self):
        return self.text(self.dy_loc)



    def luoji_163_xiexin(self):
        logging.info("开始发邮件")
        self.login_163_luoji()
        time.sleep(5)
        self.frame_connect()
        time.sleep(4)
        self.xiexin()
        time.sleep(3)
        self.shoujian()
        time.sleep(3)
        self.zhuti()
        time.sleep(2)
        self.iframe()
        time.sleep(2)
        self.body()
        time.sleep(2)
        self.frame_connect()
        time.sleep(2)
        self.send()
        time.sleep(3)
        assert '邮件发送成功' == self.dy()
        time.sleep(2)
        logging.info('结束发邮件')

